package com.zsj.enums;

/**
 * @Description:
 * @Author:
 * @Date:
 */
public enum OrderStatusEnum {

    SUCCESS("0", "成功"),
    FAILED("1", "失败"),
    PROCESSING("2", "处理中"),
    REEXCHANGE("3", "返销"),
    ;

    private final String code;

    private final String msg;

    OrderStatusEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static boolean isFinal(String orderStatus) {
        if (SUCCESS.getCode().equals(orderStatus)
                || FAILED.getCode().equals(orderStatus)
                || REEXCHANGE.getCode().equals(orderStatus)) {
            return true;
        }
        return false;
    }

    public static OrderStatusEnum findByCode(String code) {
        for (OrderStatusEnum orderStatus : OrderStatusEnum.values()) {
            if (orderStatus.getCode().equals(code)) {
                return orderStatus;
            }
        }
        return null;
    }
}
